﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QMERP.Domain.Entities;

namespace QMERP.Infrastructure.EFCore.Mappings
{
    public class CurrencyMapping : IEntityTypeConfiguration<Currency>
    {
        public void Configure(EntityTypeBuilder<Currency> builder)
        {
            builder.HasQueryFilter(x => x.IsEnable);
            builder.Property(x => x.Code).HasMaxLength(10);
            builder.Property(x => x.Name).HasMaxLength(10);
            builder.Property(x => x.Symbol).HasMaxLength(10);
            builder.Property(x => x.AcceptRate).HasPrecision(18, 6);
            builder.Property(x => x.AdjustRate).HasPrecision(18, 6);
            builder.Property(x => x.Standard);

            builder.HasIndex(x => x.Id);
            builder.HasIndex(x => x.Code);
            builder.HasIndex(x => x.Name);
        }
    }
}
